var sqliteUtil = {
	// 打开数据库
	 openDB:function(name){
		console.log('打开数据库: ');
		plus.sqlite.openDatabase({
			name: name,
			path: '_doc/'+name+'.db',
			success: function(){
				mui.toast('openDatabase success!');
			},
			fail: function(e){
				mui.toast('openDatabase failed: '+JSON.stringify(e));
			}
		});
	},
	// 执行SQL语句
	 executeSQL:function(){
		console.log('执行SQL语句: ');
		plus.sqlite.executeSql({
			name: 'first',
			sql: 'create table if not exists database("where" CHAR(110),"location" CHAR(100),"age" INT(11))',
			success: function(){
				mui.toast('executeSql success!');
				plus.sqlite.executeSql({
					name: 'first',
					sql: "insert into database values('北京','安乐林','11')",
					success: function(){
						mui.toast('executeSql success!');
					},
					fail: function(e){
						mui.toast('executeSql failed: '+JSON.stringify(e));
					}
				})
			},
			fail: function(e){
				mui.toast('executeSql failed: '+JSON.stringify(e));
			}
		});
	},
	
	// 执行SQL语句，删除数据库
	 executeSQL2:function(){
		console.log('执行SQL语句: drop table database');
		plus.sqlite.executeSql({
			name: 'first',
			sql: 'drop table database',
			success: function(e){
				mui.toast('executeSql success!');
			},
			fail: function(e){
				mui.toast('executeSql fail: '+JSON.stringify(e));
			}
		});
	},
	
	// 查询SQL语句
	 selectSQL:function(){
		console.log('查询SQL语句: ');
		plus.sqlite.selectSql({
			name: 'first',
			sql: 'select * from database',
			success: function(data){
				mui.toast('selectSql success: '+data.length);
				for(var i in data){
					mui.toast(JSON.stringify(data[i]));
				}
			},
			fail: function(e){
				mui.toast('selectSql fail: '+JSON.stringify(e));
			}
		});
	},
	
	// 关闭数据库
	 closeDB:function(){
		console.log('关闭数据库: ');
		plus.sqlite.closeDatabase({
			name: 'first',
			success: function(){
				mui.toast('closeDatabase success!');
			},
			fail: function(e){
				mui.toast('closeDatabase fail: '+JSON.stringify(e));
			}
		});
	},
	
	 isOpenDB:function(){
		if(plus.sqlite.isOpenDatabase({
			name: 'first',
			path: '_doc/test.db',
		})){
			mui.toast('Opened!');
		}else{
			mui.toast('Unopened!');
		}
	}

};
